#!/bin/sh
TFILE="/media/testdrive/result.txt"

# Esperamos hasta que se haya completado el arranque
while ! test -f /var/run/runlevel; do
	sleep 1
done

echo "----- STARTING TEST -----"
echo " EXECUTING TEST IN `pwd`" > $TFILE

OD="/usr/local/opendomo"
su -c "$OD/updatePackageList.sh" admin >> $TFILE

if su -c "$OD/installPackage.sh espeak odspeech" admin >> $TFILE 
then
	if su -c "$OD/updateInstalledPackages.sh" admin >> $TFILE
	then
		echo "OK" >> $TFILE
	else
		echo "FAILED" >> $TFILE
		reboot
	fi
else
	echo "FAILED" >> $TFILE
	reboot
fi

# Segunda parte: activando sonido
if $OD/installPackage.sh kernel_sound >> $TFILE 
then
	$OD/updateInstalledPackages.sh >> $TFILE
else
	echo "FAILED" >> $TFILE
	reboot
fi

echo "OK" >> $TFILE
reboot
